package com.team3.project.dao;


import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;

import com.team3.project.dao.impl.PublicHolidayDAOImpl;
import com.team3.project.dao.impl.UserDAOImpl;
import com.team3.project.model.LeaveRecord;
import com.team3.project.model.PublicHolidays;
import com.team3.project.model.Users;


public class App {


	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println("Start Test ");
		ApplicationContext 	appContext = new ClassPathXmlApplicationContext("spring/application-config.xml");
		BeanFactory factory = appContext;
		
		Users u = new Users("12345", "ngan", "a1232134", 8293734, "54 can", "huu@gmail.com","good", "tinhte", "boss",1000);
		//users.setId(1061);
		try {
//			UserDAO dao = (UserDAO) factory.getBean("myUserDAO");
//		Users users = dao.find(u);
//		System.out.println(users.getName());
			
			 LeaveDAO leaveRecordDAO = (LeaveDAO) factory.getBean("myLeaveDAO");
			ArrayList<LeaveRecord> list = (ArrayList<LeaveRecord>) leaveRecordDAO.findAll();
//			dao.save(u);
			for(LeaveRecord LeaveRecord : list)
			{
				System.out.println(LeaveRecord.getUsers().getId());
			}
			//leaveRecordDAO.deleteByRefNo(1);
		}catch(Exception e)
		{
			System.out.println(e.getMessage());
		}
		System.out.println("Success");
		
	}

}
